package me.zk.practice1.hw;

import java.util.*;

/**
 * @author zhangkai
 * @date 2023/8/9 14:08
 */
public class HWBJ47 {
    public static void main(String[] args) {
        System.out.println(Integer.toBinaryString(256));
        Scanner scanner = new Scanner(System.in);

        int[] nums = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int c = nums[0];

        int b = nums[1];


        Map<Integer,Integer> map = new HashMap<>();

        for (int i = 2; i < nums.length; i++) {
            int num = nums[i];
            int sum = 0;
            while (num > 0) {
                sum+=(num%256);
                num = num/256;

            }
            int s = sum%b;
            if (s < c) {
                map.put(s,map.getOrDefault(s,0)+1);
            }

        }
        int ans = 0;
        for(int value: map.values()){
            ans = Math.max(value,ans);
        }
        System.out.println(ans);
    }
}
